<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改文章')" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-article-edit" th:object="${iiArticle}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">类型：</label>
                <div class="col-sm-6">
                    <select id="categoryId" name="categoryId"  class="form-control select2" required>
                        <option value="0">请选择</option>
                        <option th:each="category:${categories}" th:value="${category.id}" th:text="${category.name}" th:selected="${iiArticle.categoryId == category.id}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">作者：</label>
                <div class="col-sm-6">
                    <select id="authorId" name="authorId"  class="form-control select2" required>
                        <option value="0">请选择</option>
                        <option th:each="author:${authors}" th:value="${author.id}" th:text="${author.name}" th:selected="${iiArticle.authorId == author.id}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">封面：</label>
                <div class="col-sm-8">
                    <input type="hidden" name="cover" th:field="*{cover}">
                    <div class="file-loading">
                        <input class="form-control image-upload" id="cover" name="file" type="file">
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">标题：</label>
                <div class="col-sm-8">
                    <input name="title" th:field="*{title}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">简介：</label>
                <div class="col-sm-8">
                    <textarea name="description" class="form-control" type="text" required rows="5">[[*{description}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">内容：</label>
                <div class="col-sm-8">
                    <script id="content" name="content" type="text/plain" th:utext="*{content}"></script>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">来源链接：</label>
                <div class="col-sm-8">
                    <input name="source" th:field="*{source}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">发布时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="publishTime" th:value="${#dates.format(iiArticle.publishTime, 'yyyy-MM-dd HH:mm')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('lk_ii_status')}">
                        <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}" required>
                        <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <th:block th:include="include :: ueditor" />
    <th:block th:include="ii/common::image-upload" />
    <script>
        var prefix = ctx + "ii/article";
        $("#form-article-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-article-edit').serialize());
            }
        }

        $("input[name='publishTime']").datetimepicker({
            format: "yyyy-mm-dd hh:ii",
            autoclose: true
        });

        $(function() {
            $('#categoryId').select2({
                placeholder:"请选择栏目",
                allowClear: true
            });
            $('#authorId').select2({
                placeholder:"请选择作者",
                allowClear: true
            });
            var ue = UE.getEditor('content');
            $("#content").css("height","380px");
        });
    </script>
</body>
</html>